package com.example.webapi.Utils;


import com.example.webapi.enums.ResponseCode;
import lombok.Data;

@Data
public class ResponseModel {
    public int code;
    public String message;
    public Object data;

    public ResponseModel(ResponseCode code) {
        this.code = code.getValue();
        this.message = code.getDescription();
    }

    public ResponseModel(ResponseCode code, String msg) {
        this.code = code.getValue();
        this.message = msg;
    }

    public ResponseModel(ResponseCode code, Object data) {
        this.code = code.getValue();
        this.message = code.getDescription();
        this.data = data;
    }

    public ResponseModel(ResponseCode code, String msg, Object data) {
        this.code = code.getValue();
        this.message = msg;
        this.data = data;
    }

    public static ResponseModel success() {
        return new ResponseModel(ResponseCode.SUCCESS);
    }

    public static ResponseModel success(String msg) {
        return new ResponseModel(ResponseCode.SUCCESS, msg);
    }

    public static ResponseModel success(Object data) {
        return new ResponseModel(ResponseCode.SUCCESS, data);
    }

    public static ResponseModel success(Object data, String msg) {

        return new ResponseModel(ResponseCode.SUCCESS, msg, data);
    }

    public static ResponseModel fail() {
        return new ResponseModel(ResponseCode.FAIL);
    }
    public static ResponseModel fail(String msg) {
        return new ResponseModel(ResponseCode.FAIL, msg);
    }

    public static ResponseModel fail(ResponseCode responseCode, String msg) {
        return new ResponseModel(responseCode, msg);
    }

    public static ResponseModel confirm(Object data) {

        return new ResponseModel(ResponseCode.CONFIRM, data);
    }
}
